import Pyro
import Pyro.core
import pojo

import time
import services

if __name__ == "__main__":
    datastoreservice = services.resolve_service("datastoreservice")
    
    t = pojo.TestData()

    print "about to initialize data store service for object TestData"

    t1 = time.time()   
    datastoreservice.initialize(t)
    t2 = time.time()

    print (t2-t1)*1000," ms"

    print "about to create schema in  data store"

    t1 = time.time()
    datastoreservice.createschema(t)
    t2 = time.time()
    print (t2-t1)*1000, " ms"

    print "about to save object with values", t

    t1 = time.time()
    datastoreservice.save(t)
    t2 = time.time()
    print (t2-t1)*1000, " ms"

    print "about to get object from data store"

    t1 = time.time()
    result = datastoreservice.get(t)
    t2 = time.time()
    print (t2-t1)*1000, " ms"

    print "about to delete schema"

    t1 = time.time()
    datastoreservice.deleteschema(t)
    t2 = time.time()
    print (t2-t1)*1000, " ms"

    for r in result:
        print r

    print "about to get count for filepath"

    f = pojo.FilePath("","")

    datastoreservice.initialize(f)

    t1 = time.time()
    result = datastoreservice.count(f)
    t2 = time.time()
    print (t2-t1)*1000, " ms"

    print "Number of file path objects : ", result
